#include "WiFi.h"    //ESP32 wifi驱动库


const char* ssid = "iPhone";           //WIFI名称
const char* password = "asdfghjk";     //WIFI密码
/********初始化WIFI*********/
bool internet_connected = false;
bool init_wifi()
{
  int connAttempts = 0;
  Serial.println("\r\nConnecting to: " + String(ssid));
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED ) {
    delay(500);
    Serial.print(".");
    if (connAttempts > 10) return false;
    connAttempts++;
  }
  return true;
}


void setup() {
  Serial.begin(115200);   //初始化调试串口
    if (init_wifi()) { // Connected to WiFi
    internet_connected = true;
    Serial.println("Internet connected");
  }
   Serial.println(WiFi.localIP());   //打印IP地址 

}

void loop() {
}
